package com.allin.social.test;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.allin.social.R;

import java.util.HashMap;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Description:
 *
 * @author: guoyongping
 * @date: 2016/4/13 11:08
 */
public class NormalRecyclerViewAdapter extends RecyclerView.Adapter<NormalRecyclerViewAdapter.NormalTextViewHolder> {

    private LayoutInflater mLayoutInflater;
    private Context mContext;
    private List<HashMap> datas;

    public NormalRecyclerViewAdapter(Context context, List<HashMap> list) {
        this.datas = list;
        this.mContext = context;
        this.mLayoutInflater = LayoutInflater.from(context);

    }


    @Override
    public NormalTextViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = mLayoutInflater.inflate(R.layout.item_recycler, parent, false);
        return new NormalTextViewHolder(view);
    }

    @Override
    public void onBindViewHolder(NormalTextViewHolder holder, int position) {

        HashMap item = datas.get(position);
        HashMap customer_doc = (HashMap) item.get("case_baseinfo");

        holder.textView.setText((CharSequence) customer_doc.get("caseName"));
    }


    @Override
    public int getItemCount() {
        return datas == null ? 0 : datas.size();
    }


    public static class NormalTextViewHolder extends RecyclerView.ViewHolder {
        @Bind(R.id.textView) TextView textView;

        NormalTextViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);

        }
    }
}
